Skip to content

Read the window from the view hierarchy across the app#25716

Open
crazytonyli wants to merge 2 commits into
trunkfrom
task/app-scene-breakdown-view-local-window-reads
Open

Read the window from the view hierarchy across the app#25716
crazytonyli wants to merge 2 commits into
trunkfrom
task/app-scene-breakdown-view-local-window-reads

Conversation

@crazytonyli

Copy link
Copy Markdown
Contributor

Note

The first commit just runs swift-format over the touched files; the actual change is the second one.

Description

Part of dropping the app's global ways of reaching its window. Each of these consumers already has a live view when it runs, so it now reads the window (or its window scene) from its own view hierarchy instead of UIApplication.mainWindow and the currentStatusBarFrame/currentStatusBarOrientation globals. Behavior is unchanged: the app is single-window, so the local window is the same one the globals resolved to.

The one site that needed more than a local read is ReaderPostCell: its cover sizing runs for off-screen cells whose own window is nil, so the window is now passed in through the cell's configure API from ReaderStreamViewController.

@crazytonyli crazytonyli added this to the 27.1 milestone Jun 29, 2026
@crazytonyli crazytonyli requested a review from jkmassel June 29, 2026 07:43
@crazytonyli crazytonyli changed the title Task/app scene breakdown view local window reads Read the window from the view hierarchy across the app Jun 29, 2026
@dangermattic

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32924
VersionPR #25716
Bundle IDorg.wordpress.alpha
Commit4f1fa0c
Installation URL3qju4e0m2q01g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32924
VersionPR #25716
Bundle IDcom.jetpack.alpha
Commit4f1fa0c
Installation URL3l63ltockjnr8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@crazytonyli crazytonyli force-pushed the task/app-scene-breakdown-view-local-window-reads branch from aaf2125 to 4f1fa0c Compare June 29, 2026 08:33
} else {

self.stackViewTopConstraint.constant = [self defaultStackDesignMargin] + [[UIApplication sharedApplication] currentStatusBarFrame].size.height;
self.stackViewTopConstraint.constant = [self defaultStackDesignMargin] + self.window.windowScene.statusBarManager.statusBarFrame.size.height;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude thinks that stackViewTopConstraint is actually unused entirely and can be removed 🤷


let cell = tableConfiguration.postCell(in: tableView, for: indexPath)
cell.configure(with: viewModel, isCompact: isCompact)
cell.configure(with: viewModel, isCompact: isCompact, window: view.window)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you were to define a property like this:

private var coverSize: ImageSize {
    let size = view.bounds.size // same as the window bounds, assuming fullscreen
    let width = isCompact
        ? min(size.width, size.height) - ReaderStreamBaseCell.insets.left * 2
        : ReaderPostCell.regularCoverWidth
    return ImageSize(scaling: CGSize(width: width, height: width),
                     scale: traitCollection.displayScale)
}

You could avoid passing the window around, and instead just pass around dimensions. That seems quite a bit simpler because the cell is more declarative/testable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants